extends KinematicBody2D

var left_bound = 0
var right_bound = 900
# 定义移动方向，1表示向右，-1表示向左
var direction = 1

const speed = 2

func _process(delta):
	move_and_collide(Vector2(direction,0)*speed)
	if position.x >= right_bound:
		direction = -1
	elif position.x <= left_bound:
		direction = 1
